SHELL=bash

include config.mk

CLEAN_OBJS=*.o
REALCLEAN_OBJS=

HADOOP_LIB_PATH=$(HADOOP_PATH)/lib

EXT=
V8LIBPATH=ext/v8/libv8.a
V8INCLUDEPATH=ext/v8/include

CFLAGS=-m32 -pedantic -Wall -g 
CPPFLAGS=-m32 -pedantic -Wall -g -I$(V8INCLUDEPATH) -I$(HADOOP_PATH)/include
LDFLAGS=-lpthread -L$(HADOOP_LIB_PATH)

###############################################################################

default: external hadoop_jsmr_container 

all: external hadoop_jsmr_container test_container

include external.mk

external: $(EXT)

jsmr.o: jsmr.cc jsmr.h 
	g++ $(CPPFLAGS) -c -o $@ $<

hadoop_jsmr_container: hadoop_jsmr_container.cc jsmr.o ext/urlparser/urlparser.o ext/v8/libv8.a 
	g++ $(LDFLAGS) $(CPPFLAGS) $^ -o $@ \
	  -DHADOOP_BIN_PATH=$(HADOOP_BIN_PATH) \
	  $(HADOOP_LIB_PATH)/libhadooppipes.a \
	  $(HADOOP_LIB_PATH)/libhadooputils.a
CLEAN_OBJS+=hadoop_jsmr_container

test_container: test_container.cc ext/v8/libv8.a jsmr.o ext/urlparser/urlparser.o
	g++ $(LDFLAGS) $(CPPFLAGS) $^ -o $@ 
CLEAN_OBJS+=test_container

docs:
	rm -rf html latex
	doxygen Doxyfile
CLEAN_OBJS+=html
CLEAN_OBJS+=latex

clean:
	rm -rf $(CLEAN_OBJS)

realclean: clean
	rm -rf $(REALCLEAN_OBJS)
